A first inspection of the dataset with 84 variables

importing the data

G = read.table("/Users/macbookpro/Documents/Bayesian Statistics/Project/Raw_data/Glicani/85 variabili/101_glicani-PreProcessed-IM-Step1-Step2-Step4-Step5-101.txt")
sum(is.na(G))
## [1] 863983

the numbers of na is substantial

 vis_miss(G,warn_large_data = FALSE)
## Warning: `gather_()` was deprecated in tidyr 1.2.0.
## ℹ Please use `gather()` instead.
## ℹ The deprecated feature was likely used in the visdat package.
##   Please report the issue at <]8;;https://github.com/ropensci/visdat/issueshttps://github.com/ropensci/visdat/issues]8;;>.

the missing data is about 56%

skim(G)
Data summary
Name G
Number of rows 18239
Number of columns 84
_______________________
Column type frequency:
numeric 84
________________________
Group variables None

Variable type: numeric

skim_variable n_missing complete_rate mean sd p0 p25 p50 p75 p100 hist
X1007.23808835211 4520 0.75 0.31 0.07 0.09 0.26 0.31 0.36 0.87 ▂▇▂▁▁
X1023.21279242663 7819 0.57 0.28 0.07 0.09 0.23 0.27 0.32 1.57 ▇▁▁▁▁
X1054.36929659222 14105 0.23 0.32 0.10 0.07 0.24 0.31 0.38 1.18 ▇▇▁▁▁
X1080.63437109277 14464 0.21 0.22 0.06 0.07 0.17 0.21 0.25 0.50 ▂▇▅▁▁
X1095.67073368166 2607 0.86 1.74 0.35 0.32 1.51 1.74 1.96 3.85 ▁▇▇▁▁
X1096.67488974389 10583 0.42 0.82 0.17 0.20 0.70 0.82 0.93 1.63 ▁▆▇▁▁
X1097.67619211616 11430 0.37 0.37 0.10 0.10 0.30 0.37 0.44 0.80 ▂▇▆▁▁
X1105.25243608966 12066 0.34 0.38 0.10 0.13 0.31 0.38 0.45 0.74 ▂▇▇▂▁
X1111.66689339176 14272 0.22 0.87 0.20 0.25 0.74 0.87 1.00 2.15 ▁▇▂▁▁
X1120.38518614217 10435 0.43 0.47 0.17 0.10 0.35 0.44 0.56 2.39 ▇▃▁▁▁
X1121.30786937301 8404 0.54 0.37 0.10 0.13 0.31 0.36 0.41 3.07 ▇▁▁▁▁
X1122.33285552465 12671 0.31 0.25 0.08 0.06 0.20 0.24 0.29 1.37 ▇▁▁▁▁
X1136.36692738743 4533 0.75 0.75 0.27 0.10 0.57 0.71 0.90 3.64 ▇▅▁▁▁
X1137.35719872902 14339 0.21 0.51 0.17 0.12 0.39 0.50 0.61 2.08 ▇▇▁▁▁
X1150.62194430748 11766 0.35 0.41 0.10 0.12 0.34 0.40 0.47 0.84 ▁▇▆▁▁
X1158.36765531336 9931 0.46 0.35 0.08 0.09 0.29 0.35 0.40 0.71 ▁▇▇▂▁
X1159.35153465909 11443 0.37 0.23 0.06 0.07 0.19 0.23 0.27 0.86 ▇▇▁▁▁
X1160.34955263613 13974 0.23 0.23 0.06 0.08 0.19 0.22 0.27 0.54 ▂▇▃▁▁
X1172.67667121138 7420 0.59 0.39 0.10 0.12 0.32 0.38 0.45 0.82 ▂▇▆▁▁
X1174.34105674359 10339 0.43 0.33 0.08 0.11 0.27 0.33 0.38 0.66 ▂▇▇▂▁
X1194.71305441144 11794 0.35 0.25 0.07 0.07 0.20 0.24 0.29 0.57 ▂▇▅▁▁
X1257.76097042394 506 0.97 3.10 0.74 0.19 2.60 3.07 3.53 12.60 ▃▇▁▁▁
X1258.76390692027 3709 0.80 1.57 0.37 0.22 1.32 1.56 1.79 5.99 ▃▇▁▁▁
X1273.74592952337 19 1.00 32.47 7.26 0.13 27.85 32.07 36.57 79.37 ▁▇▇▁▁
X1274.74924191648 1833 0.90 17.10 3.46 0.05 14.82 16.97 19.18 41.30 ▁▆▇▁▁
X1275.74652836272 2540 0.86 8.81 1.88 0.53 7.60 8.72 9.89 21.81 ▁▇▆▁▁
X1298.7935513767 4106 0.77 1.18 0.24 0.17 1.01 1.17 1.33 2.80 ▁▇▆▁▁
X1299.78851832883 9112 0.50 0.68 0.15 0.10 0.57 0.67 0.78 1.66 ▁▇▅▁▁
X1312.70555522288 13642 0.25 0.20 0.05 0.08 0.16 0.19 0.23 0.42 ▃▇▅▁▁
X1314.77923020921 13926 0.24 0.28 0.08 0.09 0.22 0.27 0.33 0.60 ▂▇▆▂▁
X1339.81344700615 14501 0.20 0.26 0.08 0.08 0.20 0.25 0.30 0.60 ▃▇▅▁▁
X1355.81342269455 7856 0.57 1.02 0.22 0.25 0.87 1.01 1.16 2.40 ▁▇▅▁▁
X1356.81729427008 10858 0.40 0.60 0.14 0.09 0.50 0.59 0.68 1.35 ▁▇▇▁▁
X1357.81803786305 13276 0.27 0.33 0.09 0.06 0.26 0.32 0.38 0.72 ▁▇▇▂▁
X1397.8251087664 8165 0.55 0.28 0.09 0.06 0.21 0.27 0.33 0.69 ▂▇▃▁▁
X1398.83247690586 13534 0.26 0.19 0.06 0.05 0.15 0.18 0.23 0.46 ▂▇▃▁▁
X1419.83984925615 13224 0.27 1.43 0.36 0.05 1.19 1.42 1.64 3.64 ▁▇▆▁▁
X1435.82424478257 209 0.99 11.89 2.93 0.08 9.98 11.65 13.56 26.85 ▁▅▇▁▁
X1439.84952205937 13692 0.25 0.42 0.12 0.09 0.33 0.41 0.49 1.07 ▂▇▃▁▁
X1460.86756694855 12067 0.34 1.15 0.28 0.05 0.96 1.13 1.31 3.33 ▁▇▂▁▁
X1501.89575378187 4718 0.74 11.59 2.61 0.03 9.99 11.48 13.11 30.82 ▁▇▅▁▁
X1517.89380823532 14479 0.21 0.35 0.11 0.10 0.27 0.34 0.42 0.79 ▂▇▆▁▁
X1603.93285349585 14325 0.21 0.29 0.06 0.07 0.25 0.29 0.33 0.54 ▁▅▇▂▁
X1604.92692536332 13110 0.28 0.25 0.06 0.06 0.21 0.24 0.28 0.47 ▁▆▇▂▁
X1645.95404319726 14203 0.22 0.15 0.04 0.04 0.12 0.15 0.18 0.33 ▁▇▅▁▁
X1722.00370903208 14543 0.20 0.18 0.06 0.06 0.14 0.17 0.21 0.43 ▃▇▃▁▁
X1906.06159070316 3886 0.79 0.54 0.15 0.06 0.44 0.54 0.63 1.45 ▁▇▃▁▁
X1907.07384539805 9219 0.49 0.40 0.12 0.08 0.32 0.40 0.48 1.08 ▂▇▃▁▁
X1927.98890691122 2939 0.84 0.27 0.08 0.07 0.21 0.26 0.32 0.79 ▃▇▂▁▁
X1928.99148346869 8223 0.55 0.21 0.06 0.06 0.17 0.21 0.25 0.57 ▃▇▂▁▁
X1929.99255956031 10753 0.41 0.16 0.05 0.06 0.13 0.16 0.19 0.41 ▃▇▃▁▁
X1953.09258073233 12594 0.31 0.15 0.04 0.05 0.11 0.14 0.17 0.34 ▃▇▃▁▁
X1954.10473321313 13962 0.23 0.14 0.05 0.05 0.11 0.14 0.17 0.37 ▅▇▂▁▁
X1969.01093012276 12619 0.31 0.17 0.04 0.03 0.14 0.17 0.20 0.37 ▁▇▇▂▁
X1994.10302397621 9497 0.48 0.16 0.05 0.04 0.13 0.16 0.19 0.40 ▂▇▃▁▁
X1995.11794029212 10797 0.41 0.17 0.05 0.05 0.13 0.16 0.20 0.47 ▃▇▂▁▁
X1996.10637962176 14482 0.21 0.14 0.04 0.04 0.11 0.13 0.16 0.32 ▂▇▅▁▁
X2010.0707542606 13760 0.25 0.14 0.04 0.04 0.12 0.14 0.17 0.37 ▂▇▃▁▁
X2026.13411594976 14307 0.22 0.13 0.04 0.04 0.10 0.12 0.15 0.29 ▃▇▅▁▁
X2067.15534850027 13085 0.28 0.11 0.04 0.03 0.09 0.11 0.14 0.33 ▅▇▂▁▁
X2115.19056235604 8002 0.56 0.16 0.06 0.03 0.12 0.15 0.19 0.43 ▃▇▃▁▁
X2116.15804918102 9911 0.46 0.16 0.05 0.04 0.12 0.15 0.19 0.42 ▃▇▃▁▁
X2117.17812491318 13156 0.28 0.13 0.04 0.03 0.10 0.12 0.15 0.33 ▃▇▃▁▁
X2131.0904558004 5911 0.68 0.17 0.06 0.03 0.13 0.16 0.21 0.50 ▃▇▂▁▁
X2132.09867199741 9715 0.47 0.16 0.06 0.03 0.12 0.16 0.20 0.47 ▃▇▂▁▁
X2133.10458924582 12988 0.29 0.14 0.05 0.03 0.11 0.14 0.17 0.39 ▃▇▃▁▁
X2156.1782470825 14355 0.21 0.13 0.04 0.04 0.10 0.12 0.15 0.33 ▃▇▃▁▁
X2172.06080944893 7567 0.59 0.11 0.04 0.03 0.08 0.10 0.14 0.32 ▅▇▃▁▁
X2173.12167061973 13793 0.24 0.13 0.04 0.04 0.09 0.12 0.15 0.36 ▅▇▂▁▁
X2213.1691692717 6872 0.62 0.09 0.04 0.02 0.07 0.09 0.12 0.32 ▇▇▂▁▁
X2214.12776174634 10438 0.43 0.10 0.04 0.02 0.07 0.10 0.13 0.31 ▅▇▃▁▁
X2215.30474997573 14072 0.23 0.10 0.04 0.03 0.07 0.10 0.12 0.29 ▆▇▂▁▁
X2303.26341177395 13894 0.24 0.13 0.04 0.03 0.10 0.12 0.16 0.38 ▃▇▂▁▁
X2318.08302732164 2155 0.88 0.10 0.04 0.03 0.07 0.09 0.12 0.36 ▇▆▂▁▁
X2319.19463247548 6704 0.63 0.11 0.05 0.03 0.07 0.10 0.14 0.42 ▇▆▁▁▁
X2320.24835445304 12408 0.32 0.11 0.04 0.03 0.07 0.10 0.13 0.33 ▇▇▂▁▁
X2375.17934903393 13125 0.28 0.10 0.04 0.03 0.07 0.10 0.12 0.35 ▇▇▂▁▁
X2481.3079356675 14522 0.20 0.10 0.04 0.03 0.07 0.10 0.12 0.31 ▆▇▂▁▁
X2521.05312515152 13249 0.27 0.09 0.04 0.03 0.06 0.08 0.11 0.27 ▇▇▂▁▁
X2521.3660375501 13332 0.27 0.10 0.04 0.02 0.07 0.09 0.12 0.30 ▅▇▂▁▁
X2522.38008739363 13256 0.27 0.10 0.04 0.03 0.07 0.09 0.12 0.27 ▆▇▃▁▁
X2626.30195630964 5870 0.68 0.09 0.04 0.02 0.06 0.09 0.12 0.34 ▇▆▁▁▁
X2627.41870733666 13456 0.26 0.10 0.04 0.03 0.07 0.10 0.13 0.33 ▇▇▂▁▁
X2628.37443696087 14041 0.23 0.09 0.04 0.03 0.06 0.08 0.11 0.29 ▇▇▂▁▁

we observe that the missing data is not uniform in the mz, there are some values for which only 20 - 30% of the pixel have a value, and this tends to be small

we replace the missing data with 0 since it means the data for that mz was under threshold

G0 = G
G0[is.na(G0)] = 0

correlation matrix

cm <- cor(G0)
colnames(G0) = substr(colnames(G0),1,4)
corrplot(cm, method = "color", tl.pos = 'n')

the correlation is not high between the features, this is different from the Lipids

preliminary plotts

pixels = read.table("/Users/macbookpro/Documents/Bayesian Statistics/Project/Raw_data/Glicani/85 variabili/101_glicani-PreProcessed-XYCoordinates-Step1-Step2-Step4-Step5-101.txt")
colnames(G0) = substr(colnames(G0),1,4)
colnames(pixels) = c("x","y")
max_n_of_pixel = read.table("/Users/macbookpro/Documents/Bayesian Statistics/Project/Raw_data/Glicani/85 variabili/101_glicani-PreProcessed-maxXY-Step1-Step2-Step4-Step5-101.txt")
Data_long            = as_tibble(data.frame( pixels, G0 ))
max_number_of_pixels = apply(Data_long[,1:2],2,max)

Data_array = matrix(NA,max_number_of_pixels[1],max_number_of_pixels[2])

Data_array = array(NA,c(max_number_of_pixels[1],max_number_of_pixels[2],ncol(G0)))

sum(is.na(G0))
## [1] 0
# there must be a better way to do this
for(k in 1:ncol(G0)){
  for(i in 1:nrow(Data_long)){
  Data_array[Data_long$x[i],Data_long$y[i],k] = G0[i,k]
  }
}

dim(Data_array)
##   x   y     
## 157 178  84
Data_very_long = reshape2::melt(Data_long,c("x","y")) %>% mutate(pixel_ind = paste0(x,"_",y), value_ind = rep(1:nrow(Data_long),ncol(G0)))
Data_very_long = Data_very_long %>% group_by(pixel_ind) %>% mutate(n = row_number()) %>% ungroup() %>% mutate(mz = as.numeric(substr(variable,2,4)))
Data_very_long = reshape2::melt(Data_long,c("x","y")) %>% mutate(pixel_ind = paste0(x,"_",y), value_ind = rep(1:nrow(Data_long),ncol(G0)))

Data_very_long = Data_very_long %>% group_by(pixel_ind) %>% mutate(n = row_number()) %>% ungroup() %>% mutate(mz = as.numeric(substr(variable,2,4)))


# subsampling to get a faster plot and not drain memory
sub_ind = sample(unique(Data_very_long$pixel_ind),1000)
# just to get the gist:
ggplot(Data_very_long %>% filter(pixel_ind %in% sub_ind))+
  geom_path(aes(x = mz, y = value, 
                col=pixel_ind, 
                group = pixel_ind),alpha=.5)+theme_bw()+theme(legend.position = "none")+xlab("m.z")+scale_color_viridis_d(option = "A")+
  scale_x_continuous(n.breaks = 20)

investigating the different peaks

first interval

the first values are quite noisy

first peak

here we start seeing the spikes, they are for 125 a few spots the rest is quite uniform, for 127 we have it quite spread out

there are some holes in the data, the only structure is the one in 127

noisy intervall

still quite noisy with some spots with high values

seond peak

we can see some struture in 143 same struture as before

third peak

150 is another level where wee have features the rest is just noise

noisy intervall

just noise and low values, the same holes repeats the next is still just noise

this is just noise up to the end of the available mz

let us compare the peaks

it is the same peaks with some degraded points

strange patterns

there are this two strange patterns, the conentrates spikes anf the holes

PCA on vecotr data (NON Functional)

pca = princomp(G0)
plot(pca)

summary(pca)
## Importance of components:
##                           Comp.1    Comp.2    Comp.3     Comp.4     Comp.5
## Standard deviation     9.4844228 5.1242938 4.1983528 3.03965996 1.47092223
## Proportion of Variance 0.6036961 0.1762238 0.1182917 0.06200784 0.01452031
## Cumulative Proportion  0.6036961 0.7799199 0.8982117 0.96021953 0.97473985
##                             Comp.6      Comp.7      Comp.8      Comp.9
## Standard deviation     0.657336674 0.645979110 0.610847759 0.552186490
## Proportion of Variance 0.002899828 0.002800487 0.002504163 0.002046294
## Cumulative Proportion  0.977639675 0.980440162 0.982944325 0.984990619
##                            Comp.10     Comp.11     Comp.12     Comp.13
## Standard deviation     0.516524757 0.498932917 0.473546948 0.443865738
## Proportion of Variance 0.001790519 0.001670632 0.001504952 0.001322208
## Cumulative Proportion  0.986781138 0.988451770 0.989956722 0.991278930
##                             Comp.14     Comp.15      Comp.16      Comp.17
## Standard deviation     0.3834690731 0.348093244 0.3359170408 0.2958763279
## Proportion of Variance 0.0009868639 0.000813182 0.0007572873 0.0005875124
## Cumulative Proportion  0.9922657942 0.993078976 0.9938362634 0.9944237758
##                             Comp.18      Comp.19      Comp.20      Comp.21
## Standard deviation     0.2259710597 0.2104915001 0.1919069696 0.1892836132
## Proportion of Variance 0.0003426906 0.0002973485 0.0002471599 0.0002404488
## Cumulative Proportion  0.9947664664 0.9950638149 0.9953109748 0.9955514236
##                             Comp.22      Comp.23      Comp.24     Comp.25
## Standard deviation     0.1858510617 0.1848481951 0.1825676413 0.180579729
## Proportion of Variance 0.0002318071 0.0002293121 0.0002236888 0.000218844
## Cumulative Proportion  0.9957832307 0.9960125428 0.9962362316 0.996455076
##                             Comp.26      Comp.27      Comp.28      Comp.29
## Standard deviation     0.1758785370 0.1657935510 0.1640670459 0.1608873772
## Proportion of Variance 0.0002075976 0.0001844726 0.0001806506 0.0001737163
## Cumulative Proportion  0.9966626731 0.9968471457 0.9970277963 0.9972015125
##                             Comp.30      Comp.31      Comp.32      Comp.33
## Standard deviation     0.1501372965 0.1478498431 0.1461086497 0.1378333163
## Proportion of Variance 0.0001512773 0.0001467028 0.0001432677 0.0001274985
## Cumulative Proportion  0.9973527898 0.9974994926 0.9976427603 0.9977702588
##                             Comp.34      Comp.35      Comp.36      Comp.37
## Standard deviation     0.1364428678 0.1304432382 0.1235310915 1.212386e-01
## Proportion of Variance 0.0001249391 0.0001141931 0.0001024116 9.864571e-05
## Cumulative Proportion  0.9978951979 0.9980093909 0.9981118025 9.982104e-01
##                             Comp.38      Comp.39      Comp.40      Comp.41
## Standard deviation     1.201414e-01 1.153015e-01 1.130472e-01 1.100120e-01
## Proportion of Variance 9.686829e-05 8.922088e-05 8.576614e-05 8.122255e-05
## Cumulative Proportion  9.983073e-01 9.983965e-01 9.984823e-01 9.985635e-01
##                             Comp.42      Comp.43      Comp.44      Comp.45
## Standard deviation     1.085717e-01 1.068849e-01 1.048044e-01 9.974492e-02
## Proportion of Variance 7.910974e-05 7.667065e-05 7.371493e-05 6.676951e-05
## Cumulative Proportion  9.986426e-01 9.987193e-01 9.987930e-01 9.988598e-01
##                             Comp.46      Comp.47      Comp.48      Comp.49
## Standard deviation     9.150374e-02 9.007107e-02 8.666905e-02 8.629786e-02
## Proportion of Variance 5.619197e-05 5.444615e-05 5.041092e-05 4.998004e-05
## Cumulative Proportion  9.989160e-01 9.989704e-01 9.990208e-01 9.990708e-01
##                             Comp.50      Comp.51      Comp.52      Comp.53
## Standard deviation     8.569246e-02 8.512367e-02 8.433057e-02 8.382657e-02
## Proportion of Variance 4.928126e-05 4.862921e-05 4.772727e-05 4.715849e-05
## Cumulative Proportion  9.991201e-01 9.991687e-01 9.992165e-01 9.992636e-01
##                             Comp.54      Comp.55      Comp.56      Comp.57
## Standard deviation     8.304057e-02 8.264791e-02 8.104304e-02 7.517147e-02
## Proportion of Variance 4.627828e-05 4.584166e-05 4.407863e-05 3.792299e-05
## Cumulative Proportion  9.993099e-01 9.993557e-01 9.993998e-01 9.994377e-01
##                             Comp.58      Comp.59      Comp.60      Comp.61
## Standard deviation     6.922338e-02 6.639589e-02 0.0661546426 6.463111e-02
## Proportion of Variance 3.215898e-05 2.958551e-05 0.0000293709 2.803366e-05
## Cumulative Proportion  9.994699e-01 9.994995e-01 0.9995288532 9.995569e-01
##                             Comp.62      Comp.63      Comp.64      Comp.65
## Standard deviation     6.422775e-02 6.270395e-02 6.166750e-02 6.055746e-02
## Proportion of Variance 2.768484e-05 2.638677e-05 2.552168e-05 2.461115e-05
## Cumulative Proportion  9.995846e-01 9.996110e-01 9.996365e-01 9.996611e-01
##                             Comp.66      Comp.67      Comp.68      Comp.69
## Standard deviation     5.892325e-02 5.769626e-02 5.751790e-02 5.713134e-02
## Proportion of Variance 2.330075e-05 2.234045e-05 2.220254e-05 2.190511e-05
## Cumulative Proportion  9.996844e-01 9.997067e-01 9.997289e-01 9.997508e-01
##                             Comp.70      Comp.71      Comp.72      Comp.73
## Standard deviation     5.599623e-02 5.498231e-02 5.459108e-02 5.392416e-02
## Proportion of Variance 2.104331e-05 2.028815e-05 2.000046e-05 1.951477e-05
## Cumulative Proportion  9.997719e-01 9.997922e-01 9.998122e-01 9.998317e-01
##                             Comp.74      Comp.75      Comp.76      Comp.77
## Standard deviation     5.381131e-02 5.309932e-02 5.235614e-02 4.978128e-02
## Proportion of Variance 1.943317e-05 1.892232e-05 1.839636e-05 1.663139e-05
## Cumulative Proportion  9.998511e-01 9.998700e-01 9.998884e-01 9.999051e-01
##                             Comp.78      Comp.79      Comp.80      Comp.81
## Standard deviation     0.0494976227 4.895491e-02 4.786210e-02 4.526676e-02
## Proportion of Variance 0.0000164424 1.608382e-05 1.537376e-05 1.375167e-05
## Cumulative Proportion  0.9999215125 9.999376e-01 9.999530e-01 9.999667e-01
##                             Comp.82      Comp.83      Comp.84
## Standard deviation     4.306283e-02 4.154729e-02 3.712239e-02
## Proportion of Variance 1.244519e-05 1.158463e-05 9.248439e-06
## Cumulative Proportion  9.999792e-01 9.999908e-01 1.000000e+00

we nee much more components to get a googe percentage of the variance than in the lipid case

PCA1 = ggplot(Data_long %>% mutate(pca1 = pca$scores[,1]))+ theme_bw()+
  geom_tile(aes(x=x,y=y,fill = pca1))+scale_fill_viridis_c(option = "A",na.value = "red")+
  theme_void()+theme(legend.position = "bottom")
PCA2 = ggplot(Data_long %>% mutate(pca2 = pca$scores[,2]))+ theme_bw()+
  geom_tile(aes(x=x,y=y,fill = pca2))+scale_fill_viridis_c(option = "A",na.value = "red")+
  theme_void()+theme(legend.position = "bottom")
PCA3 = ggplot(Data_long %>% mutate(pca1 = pca$scores[,3]))+ theme_bw()+
  geom_tile(aes(x=x,y=y,fill = pca1))+scale_fill_viridis_c(option = "A",na.value = "red")+
  theme_void()+theme(legend.position = "bottom")
PCA4 = ggplot(Data_long %>% mutate(pca2 = pca$scores[4]))+ theme_bw()+
  geom_tile(aes(x=x,y=y,fill = pca2))+scale_fill_viridis_c(option = "A",na.value = "red")+
  theme_void()+theme(legend.position = "bottom")
PCA5 = ggplot(Data_long %>% mutate(pca1 = pca$scores[,5]))+ theme_bw()+
  geom_tile(aes(x=x,y=y,fill = pca1))+scale_fill_viridis_c(option = "A",na.value = "red")+
  theme_void()+theme(legend.position = "bottom")
PCA6 = ggplot(Data_long %>% mutate(pca2 = pca$scores[,6]))+ theme_bw()+
  geom_tile(aes(x=x,y=y,fill = pca2))+scale_fill_viridis_c(option = "A",na.value = "red")+
  theme_void()+theme(legend.position = "bottom")


PCA1+PCA2+PCA3+PCA4+PCA5+PCA6

comparing thi with the peaks

PCA1 = ggplot(Data_long %>% mutate(pca1 = pca$scores[,1]))+ theme_bw()+
  geom_tile(aes(x=x,y=y,fill = pca1))+scale_fill_viridis_c(option = "A",na.value = "red")+
  theme_void()+theme(legend.position = "bottom")
PCA2 = ggplot(Data_long %>% mutate(pca2 = pca$scores[,2]))+ theme_bw()+
  geom_tile(aes(x=x,y=y,fill = pca2))+scale_fill_viridis_c(option = "A",na.value = "red")+
  theme_void()+theme(legend.position = "bottom")
PCA3 = ggplot(Data_long %>% mutate(pca1 = pca$scores[,3]))+ theme_bw()+
  geom_tile(aes(x=x,y=y,fill = pca1))+scale_fill_viridis_c(option = "A",na.value = "red")+
  theme_void()+theme(legend.position = "bottom")
P1 = ggplot(Data_long)+
  geom_tile(aes(x=x,y=y,fill = X143))+scale_fill_viridis_c(option = "A",na.value = "red")+
  theme_void()+theme(legend.position = "bottom")
P2 = ggplot(Data_long)+
  geom_tile(aes(x=x,y=y,fill = X127))+scale_fill_viridis_c(option = "A",na.value = "red")+
  theme_void()+theme(legend.position = "bottom")

P3 = ggplot(Data_long)+
  geom_tile(aes(x=x,y=y,fill = X127.2))+scale_fill_viridis_c(option = "A",na.value = "red")+
  theme_void()+theme(legend.position = "bottom")


PCA1+PCA2+PCA3+P1+P2+P3

Plotting the principal components

first component

this are the three clear peaks that one can see in the data

second component

third component